<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>SQL示例功能演示</title>
    <style>
        body {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
            line-height: 1.6;
            margin: 0;
            padding: 20px;
            background: #f5f5f5;
        }
        .container {
            max-width: 1200px;
            margin: 0 auto;
            background: white;
            border-radius: 12px;
            padding: 30px;
            box-shadow: 0 4px 20px rgba(0,0,0,0.1);
        }
        h1 {
            color: #1890ff;
            text-align: center;
            margin-bottom: 30px;
        }
        .feature-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
            gap: 20px;
            margin-bottom: 30px;
        }
        .feature-card {
            background: #f8fbff;
            border: 2px solid #e6f7ff;
            border-radius: 8px;
            padding: 20px;
        }
        .feature-card h3 {
            color: #1890ff;
            margin-top: 0;
        }
        .demo-section {
            background: #fafafa;
            border-radius: 8px;
            padding: 20px;
            margin: 20px 0;
        }
        .code-block {
            background: #1f1f1f;
            color: #f8f8f2;
            padding: 15px;
            border-radius: 6px;
            overflow-x: auto;
            font-family: 'Monaco', 'Menlo', monospace;
            font-size: 14px;
            line-height: 1.4;
        }
        .sql-keyword { color: #66d9ef; }
        .sql-string { color: #e6db74; }
        .sql-comment { color: #75715e; }
        .btn {
            background: #1890ff;
            color: white;
            border: none;
            padding: 10px 20px;
            border-radius: 4px;
            cursor: pointer;
            text-decoration: none;
            display: inline-block;
            margin: 10px 10px 10px 0;
            transition: all 0.2s;
        }
        .btn:hover {
            background: #40a9ff;
            transform: translateY(-1px);
        }
        .highlight {
            background: #fff2e8;
            padding: 15px;
            border-left: 4px solid #fa8c16;
            border-radius: 4px;
            margin: 15px 0;
        }
        .steps {
            counter-reset: step-counter;
        }
        .step {
            counter-increment: step-counter;
            margin: 20px 0;
            padding: 15px;
            background: #f0f9ff;
            border-radius: 6px;
            position: relative;
            padding-left: 60px;
        }
        .step::before {
            content: counter(step-counter);
            position: absolute;
            left: 20px;
            top: 15px;
            background: #1890ff;
            color: white;
            width: 24px;
            height: 24px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: bold;
            font-size: 12px;
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>🚀 MySQL EXPLAIN 可视化工具 - SQL示例功能演示</h1>
        
        <div class="highlight">
            <strong>🎉 新功能上线！</strong> 现在可以为每个执行计划节点获取对应的SQL查询示例，并一键复制执行！
        </div>

        <div class="feature-grid">
            <div class="feature-card">
                <h3>📝 智能SQL示例</h3>
                <p>根据节点类型自动生成相关的SQL查询示例，包括基础查询、优化查询和EXPLAIN语句。</p>
            </div>
            <div class="feature-card">
                <h3>📋 一键复制</h3>
                <p>支持一键复制SQL语句和EXPLAIN语句到剪贴板，方便在数据库中直接执行测试。</p>
            </div>
            <div class="feature-card">
                <h3>🎯 上下文适配</h3>
                <p>智能提取表名和索引信息，生成更贴近实际场景的SQL示例。</p>
            </div>
            <div class="feature-card">
                <h3>🚀 性能优化</h3>
                <p>针对性能警告自动生成优化建议SQL，帮助快速解决性能问题。</p>
            </div>
        </div>

        <div class="demo-section">
            <h2>🔧 使用步骤</h2>
            <div class="steps">
                <div class="step">
                    <strong>输入EXPLAIN数据</strong><br>
                    在工具中粘贴MySQL EXPLAIN输出结果，支持Tree、JSON、Traditional格式
                </div>
                <div class="step">
                    <strong>解析生成图表</strong><br>
                    点击"解析执行计划"按钮，生成可视化的执行计划图表
                </div>
                <div class="step">
                    <strong>点击节点查看详情</strong><br>
                    点击图表中的任意节点，右侧会显示详细信息面板
                </div>
                <div class="step">
                    <strong>查看SQL示例</strong><br>
                    在详情面板中找到"SQL示例"部分，查看相关的查询示例
                </div>
                <div class="step">
                    <strong>一键复制执行</strong><br>
                    点击"复制SQL"或"复制EXPLAIN"按钮，在数据库中执行测试
                </div>
            </div>
        </div>

        <div class="demo-section">
            <h2>💡 示例展示</h2>
            <h3>全表扫描节点示例</h3>
            <div class="code-block">
<span class="sql-comment">-- 全表扫描示例：查询所有用户</span>
<span class="sql-keyword">SELECT</span> * <span class="sql-keyword">FROM</span> users;

<span class="sql-comment">-- 对应的EXPLAIN语句</span>
<span class="sql-keyword">EXPLAIN</span> <span class="sql-keyword">SELECT</span> * <span class="sql-keyword">FROM</span> users;
            </div>

            <h3>索引扫描节点示例</h3>
            <div class="code-block">
<span class="sql-comment">-- 索引扫描示例：主键查询</span>
<span class="sql-keyword">SELECT</span> * <span class="sql-keyword">FROM</span> users <span class="sql-keyword">WHERE</span> id = <span class="sql-string">123</span>;

<span class="sql-comment">-- 对应的EXPLAIN语句</span>
<span class="sql-keyword">EXPLAIN</span> <span class="sql-keyword">SELECT</span> * <span class="sql-keyword">FROM</span> users <span class="sql-keyword">WHERE</span> id = <span class="sql-string">123</span>;
            </div>

            <h3>性能优化建议示例</h3>
            <div class="code-block">
<span class="sql-comment">-- 优化建议：添加索引避免全表扫描</span>
<span class="sql-keyword">ALTER</span> <span class="sql-keyword">TABLE</span> users <span class="sql-keyword">ADD</span> <span class="sql-keyword">INDEX</span> idx_status (status);

<span class="sql-comment">-- 分析表统计信息</span>
<span class="sql-keyword">ANALYZE</span> <span class="sql-keyword">TABLE</span> users;
            </div>
        </div>

        <div class="demo-section">
            <h2>🎨 支持的节点类型</h2>
            <ul>
                <li><strong>表访问操作</strong>：全表扫描、索引扫描、索引查找</li>
                <li><strong>连接操作</strong>：嵌套循环连接、哈希连接</li>
                <li><strong>排序分组</strong>：排序操作、分组操作、聚合函数</li>
                <li><strong>子查询</strong>：子查询、物化操作</li>
                <li><strong>高级功能</strong>：窗口函数、过滤条件、去重操作</li>
            </ul>
        </div>

        <div class="demo-section">
            <h2>🌟 主要特性</h2>
            <ul>
                <li>✅ 支持所有主要的MySQL执行计划节点类型</li>
                <li>✅ 智能生成上下文相关的SQL示例</li>
                <li>✅ 一键复制功能，支持现代和传统浏览器</li>
                <li>✅ SQL语法高亮显示，支持多主题</li>
                <li>✅ 性能优化建议自动生成</li>
                <li>✅ 响应式设计，移动端友好</li>
                <li>✅ 展开/收起功能，节省屏幕空间</li>
            </ul>
        </div>

        <div style="text-align: center; margin-top: 40px;">
            <a href="index.html" class="btn">🚀 立即体验</a>
            <a href="SQL示例功能说明.md" class="btn" style="background: #52c41a;">📖 详细文档</a>
        </div>

        <div style="text-align: center; margin-top: 30px; color: #666; font-size: 14px;">
            <p>MySQL EXPLAIN 可视化工具 - 让数据库性能优化更简单</p>
        </div>
    </div>
</body>
</html>
